package cn.itlaobing.model;

import java.util.List;

/**
 * Created by Administrator on 2017-11-10.
 */
public class PanationVir<T> {
    public static final Integer FAULT_SIZE=5;
    private List<T> list;
    private Integer total;
    private Integer size=FAULT_SIZE;
    private Integer index;

    public PanationVir()
    {

    }
    public PanationVir(List<T> list, Integer total, Integer size, Integer index) {
        this.list = list;
        this.total = total;
        this.size = size;
        this.index = index;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    public Integer getTotal() {
        return total;
    }

    public void setTotal(Integer total) {
        this.total = total;
    }

    public Integer getSize() {
        return size;
    }

    public void setSize(Integer size) {
        this.size = size;
    }

    public Integer getIndex() {
        return index;
    }

    public void setIndex(Integer index) {
        this.index = index;
    }
    public Integer getPage() {
        return total % size == 0 ? total / size : total / size + 1;
    }

    //是否有上一页
    public Boolean getFirst() {
        return index > 1;
    }

    //是否有下一页
    public Boolean getLast() {
        return index < getPage();
    }

    //针对没有上一页如何操作
    public Integer getFirstpage() {
        if (getFirst()) {
            return index - 1;
        } else {
            return 1;
        }
    }

    //针对有没有下一页操作
    public Integer getLastpage() {
        if (getLast()) {
            return index + 1;
        } else {
            return getPage();
        }
    }
}
